﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Percolation.Gui
{
    public partial class NewProjectForm : Form
    {
        public NewProjectForm()
        {
            InitializeComponent();
        }

        public String ProjectName { get; private set; }

        private void m_okButton_Click(object sender, EventArgs e)
        {
            if (!validateProjectName())
                return;

            ProjectName = m_projectNameTextBox.Text;
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        private void m_cancelButton_Click(object sender, EventArgs e)
        {
            ProjectName = "";
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
            Close();
        }

        private bool validateProjectName()
        {
            if (m_projectNameTextBox.Text == "")
            {
                m_errorProvider.SetError(m_projectNameTextBox, "Name must not be empty!");
                return false;
            }

            m_errorProvider.SetError(m_projectNameTextBox, "");
            return true;
        }
    }
}
